/**
 * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.well.cloud.base.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * 所属微信名
 *
 * @author wison
 * @Date 2017年1月22日 下午12:14:59
 */
@Getter
public enum WXTypeEnums {

    HTOLOGY("HTOLOGY", "wx3491f9d4585a2ed7","htology资讯","4cEWlzPj7YdBX4E5UkHhLr5m9VbNeNZbzCDB3LO75KM"),
    ONCO("ONCO","wxecd57dade6375cf4","ONCO前沿资讯","51LoLV2pUorDgiuZyHcVg88HUQ_yiVoEhRfiOdvalkg"),
    ONCO_SUB("ONCO_SUB","wx9f672a28698fed53","ONCO前沿(订阅号)","####");

    String code;
    String appId;
    String message;
    String tempId;

    WXTypeEnums(String code,String appId,  String message, String tempId) {
        this.code = code;
        this.appId = appId;
        this.message = message;
        this.tempId = tempId;
    }

    /**
     * 根据code返回tempId
     * @param code
     * @return
     */
    public static String getTempIdByCode(String code) {
        if (code == null) {
            return "";
        } else {
            for (WXTypeEnums s : WXTypeEnums.values()) {
                if (s.getCode().equals(code)) {
                    return s.getTempId();
                }
            }
            return "";
        }
    }

    /**
     * 根据 appId 返回code
     * @param appId
     * @return
     */
    public static String getCodeByAppId(String appId) {
        if (appId == null) {
            return "";
        } else {
            for (WXTypeEnums s : WXTypeEnums.values()) {
                if (s.getAppId().equals(appId)) {
                    return s.getCode();
                }
            }
            return "";
        }
    }

    /**
     * 根据code返回枚举对象
     * @param code
     * @return
     */
    public static WXTypeEnums getWXTypeEnumsByCode(String code){
        for(WXTypeEnums wxTypeEnums : WXTypeEnums.values()){
            if(StringUtils.equals(code, wxTypeEnums.getCode())){
                return wxTypeEnums;
            }
        }
        return null;
    }
}
